package com.android.infantschool.model.mvp.model;

import android.util.Log;

import com.android.infantschool.bean.AddJobBean;
import com.android.infantschool.bean.AppUpdateBean;
import com.android.infantschool.bean.AskForLeaveBean;
import com.android.infantschool.bean.AuthCodeBean;
import com.android.infantschool.bean.BabyClassPhotoBean;
import com.android.infantschool.bean.BabyFootBean;
import com.android.infantschool.bean.BabyInfoBean;
import com.android.infantschool.bean.BabyParentsBean;
import com.android.infantschool.bean.BabyRemarkBean;
import com.android.infantschool.bean.BabySyllabusBean;
import com.android.infantschool.bean.BeautifulTeacherBean;
import com.android.infantschool.bean.BindingQrCodeBean;
import com.android.infantschool.bean.ChangPswBean;
import com.android.infantschool.bean.ClockingBaseBean;
import com.android.infantschool.bean.ClockingClockingNotBean;
import com.android.infantschool.bean.ClockingClockingYesBean;
import com.android.infantschool.bean.ClockingLeaveBean;
import com.android.infantschool.bean.DynamicBean;
import com.android.infantschool.bean.HiddenManagerBean;
import com.android.infantschool.bean.HomeBannerBean;
import com.android.infantschool.bean.InfromBean;
import com.android.infantschool.bean.JobBean;
import com.android.infantschool.bean.LoginBean;
import com.android.infantschool.bean.ParentsBindingBean;
import com.android.infantschool.bean.PatriarchBean;
import com.android.infantschool.bean.ResponseBean;
import com.android.infantschool.bean.TelBookBean;
import com.android.infantschool.bean.TemperatureRecodeBean;
import com.android.infantschool.bean.ToViewBindingBean;
import com.android.infantschool.model.http.RetrofitClint;
import com.android.infantschool.model.http.RxApiManager;
import com.android.infantschool.util.JsonGet;

import java.io.IOException;
import java.util.Map;

import okhttp3.ResponseBody;
import rx.Observable;
import rx.Subscriber;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * @author Administrator
 * @particulars
 * @time 2019\7\24 0024 8:54
 * @class describe
 */
public class ApiModelImpl implements ApiModel {

    private String TAG = getClass().getCanonicalName();

    /**
     * 用户登录
     *
     * @param listener
     * @param map      携带的参数
     */
    @Override
    public void login(final OnApiListener listener, Map<String, String> map) {

        Observable<LoginBean> observable = RetrofitClint.getApi().login(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<LoginBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "43-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(LoginBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("login", subscription);
    }

    /**
     * 获取验证码
     *
     * @param listener
     * @param map
     */
    @Override
    public void getAuthCode(final OnApiListener listener, Map<String, String> map) {
        Observable<AuthCodeBean> observable = RetrofitClint.getApi().getAuthCode(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<AuthCodeBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "96-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(AuthCodeBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("authcode", subscription);
    }

    /**
     * 用户修改密码
     *
     * @param listener
     * @param map
     */
    @Override
    public void postChangePsw(final OnApiListener listener, Map<String, String> map) {
        Observable<ChangPswBean> observable = RetrofitClint.getApi().postChangPsw(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ChangPswBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "156-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ChangPswBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("changepsw", subscription);
    }

    /**
     * 获取首页轮播图
     *
     * @param listener
     * @param map
     */
    @Override
    public void getHomeBanner(final OnApiListener listener, Map<String, String> map) {
        Observable<HomeBannerBean> observable = RetrofitClint.getApi().getHomeBanner(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<HomeBannerBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "180-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(HomeBannerBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("homebanner", subscription);
    }

    /**
     * 获取通讯录
     *
     * @param listener
     * @param map
     */
    @Override
    public void getTelBook(final OnApiListener listener, Map<String, String> map) {
        Observable<TelBookBean> observable = RetrofitClint.getApi().getTelBook(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<TelBookBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "240-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(TelBookBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("telbook", subscription);
    }

    /**
     * 获取课程表
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBabySyllabus(final OnApiListener listener, Map<String, String> map) {
        Observable<BabySyllabusBean> observable = RetrofitClint.getApi().getBabySyllabus(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BabySyllabusBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "282-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BabySyllabusBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("babySyllabus", subscription);
    }

    /**
     * 上传课程表
     *
     * @param listener
     * @param map
     */
    @Override
    public void postCurriculum(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postCurriculum(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "324-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("insertcurriculum", subscription);
    }

    /**
     * 获取宝宝评语
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBabyRemark(final OnApiListener listener, Map<String, String> map) {
        Observable<BabyRemarkBean> observable = RetrofitClint.getApi().getBabyRemark(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BabyRemarkBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "366-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BabyRemarkBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("babyremark", subscription);
    }

    /**
     * 添加宝宝评语
     *
     * @param listener
     * @param map
     */
    @Override
    public void postAddRemark(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postAddRemark(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "408-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("addremark", subscription);
    }

    /**
     * 添加亲子作业
     *
     * @param listener
     * @param map
     */
    @Override
    public void postAddJob(final OnApiListener listener, Map<String, String> map) {
        Observable<AddJobBean> observable = RetrofitClint.getApi().postAddJob(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<AddJobBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "450-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(AddJobBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("addjob", subscription);
    }

    /**
     * 获取所有亲子作业
     *
     * @param listener
     * @param map
     */
    @Override
    public void getJob(final OnApiListener listener, Map<String, String> map) {
        Observable<JobBean> observable = RetrofitClint.getApi().getJob(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<JobBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "492-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(JobBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("job", subscription);
    }

    /**
     * 获取家长留言
     *
     * @param listener
     * @param map
     */
    @Override
    public void getPatriarch(final OnApiListener listener, Map<String, String> map) {
        Observable<PatriarchBean> observable = RetrofitClint.getApi().getPatriarch(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<PatriarchBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "534-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(PatriarchBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("patriarch", subscription);
    }

    /**
     * 获取班级相册
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBabyClassPhoto(final OnApiListener listener, Map<String, String> map) {
        Observable<BabyClassPhotoBean> observable = RetrofitClint.getApi().getBabyClassPhoto(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BabyClassPhotoBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "576-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BabyClassPhotoBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("classphoto", subscription);
    }

    /**
     * 获取宝宝饮食
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBabyFoot(final OnApiListener listener, Map<String, String> map) {
        Observable<BabyFootBean> observable = RetrofitClint.getApi().getBabyFoot(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BabyFootBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "618-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BabyFootBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("babyfoot", subscription);
    }

    /**
     * 拉取学生列表
     *
     * @param listener
     * @param map
     */
    @Override
    public void getClockBase(final OnApiListener listener, Map<String, String> map) {
        Observable<ClockingBaseBean> observable = RetrofitClint.getApi().getClockClockingNot(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ClockingBaseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "660-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ClockingBaseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("clockingbase", subscription);
    }

    /**
     * 获取宝宝数据
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBabyInfo(final OnApiListener listener, Map<String, String> map) {
        Observable<BabyInfoBean> observable = RetrofitClint.getApi().getBabyInfo(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BabyInfoBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "702-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BabyInfoBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("babyinfo", subscription);
    }

    /**
     * 上传宝宝体温
     *
     * @param listener
     * @param map
     */
    @Override
    public void postAddTemperature(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postAddTemperature(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "744-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("addtemperature", subscription);
    }

    /**
     * 获取宝宝测温记录
     *
     * @param listener
     * @param map
     */
    @Override
    public void postTemperatureRecode(final OnApiListener listener, Map<String, String> map) {
        Observable<TemperatureRecodeBean> observable = RetrofitClint.getApi().postTemperatureRecode(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<TemperatureRecodeBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "786-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(TemperatureRecodeBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("temperaturerecode", subscription);
    }

    /**
     * 考勤接口
     *
     * @param listener
     * @param map
     * @param type     已到或未到
     */
    @Override
    public void getClockingClocking(final ApiListener listener, Map<String, String> map, final int type) {
        Observable<ResponseBody> observable = RetrofitClint.getApi().getClockingClocking(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBody>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "829-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString(), type);
                        }
                    }

                    @Override
                    public void onNext(ResponseBody body) {
                        if (body != null) {
                            try {
                                String data = body.string();
                                Log.e(TAG, "data:" + data);
                                if (listener != null) {
                                    if (type == 2) {//考勤未到
                                        ClockingClockingNotBean clockingNotBean = null;
                                        try {
                                            clockingNotBean = JsonGet.getGson(data, new ClockingClockingNotBean());
                                        } catch (Exception e) {
                                            clockingNotBean = null;
                                        }
                                        listener.onSuccess(clockingNotBean, type);
                                    }
                                    if (type == 1) {//考勤已到
                                        ClockingClockingYesBean clockingYesBean = null;
                                        try {
                                            clockingYesBean = JsonGet.getGson(data, new ClockingClockingYesBean());
                                        } catch (Exception e) {
                                            clockingYesBean = null;
                                        }
                                        listener.onSuccess(clockingYesBean, type);
                                    }
                                }
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("clockingclocking", subscription);
    }

    /**
     * 请假接口
     *
     * @param listener
     * @param map
     */
    @Override
    public void getClockingLeave(final OnApiListener listener, Map<String, String> map) {
        Observable<ClockingLeaveBean> observable = RetrofitClint.getApi().getClockLeave(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ClockingLeaveBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "883-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ClockingLeaveBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("clockingleave", subscription);
    }

    /**
     * 签退
     *
     * @param listener
     * @param map
     */
    @Override
    public void postSignOut(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postSignOut(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "925-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("signOut", subscription);
    }

    /**
     * 请假审批
     *
     * @param listener
     * @param map
     */
    @Override
    public void postLeaveApprove(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postLeaveApprove(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "967-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("clockingleave", subscription);
    }

    /**
     * 发布动态
     *
     * @param listener
     * @param map
     */
    @Override
    public void postDynamic(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postDynamic(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1009-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("releasedynamic", subscription);
    }

    /**
     * 获取动态列表
     *
     * @param listener
     * @param map
     */
    @Override
    public void getDynamicList(final OnApiListener listener, Map<String, String> map) {
        Observable<DynamicBean> observable = RetrofitClint.getApi().getDynamicList(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<DynamicBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1052-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(DynamicBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("dynamiclist", subscription);
    }

    /**
     * 获取最美教师
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBeautifulTeacher(final OnApiListener listener, Map<String, String> map) {
        Observable<BeautifulTeacherBean> observable = RetrofitClint.getApi().getBeautifulTeacher(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BeautifulTeacherBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1052-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BeautifulTeacherBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("beautifulteacher", subscription);
    }

    /**
     * 获取家长绑定列表
     *
     * @param listener
     * @param map
     */
    @Override
    public void getParentsList(final OnApiListener listener, Map<String, String> map) {
        Observable<ParentsBindingBean> observable = RetrofitClint.getApi().getParentsList(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ParentsBindingBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1138-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ParentsBindingBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("parentslist", subscription);
    }

    /**
     * 获取家长绑定二维码
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBabyBindingQrCode(final OnApiListener listener, Map<String, String> map) {
        Observable<BindingQrCodeBean> observable = RetrofitClint.getApi().getBabyBindingQrCode(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BindingQrCodeBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1181-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BindingQrCodeBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("babybindingqrcode", subscription);
    }

    /**
     * 教师请假调休
     *
     * @param listener
     * @param map
     */
    @Override
    public void getAskForLeave(final OnApiListener listener, Map<String, String> map) {
        Observable<AskForLeaveBean> observable = RetrofitClint.getApi().getAskForLeave(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<AskForLeaveBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1224-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(AskForLeaveBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("askForLeavelist", subscription);
    }

    /**
     * 查看已绑定的家长
     *
     * @param listener
     * @param map
     */
    @Override
    public void getToViewBinging(final OnApiListener listener, Map<String, String> map) {
        Observable<ToViewBindingBean> observable = RetrofitClint.getApi().getToViewBinging(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ToViewBindingBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1224-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ToViewBindingBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("toViewBinding", subscription);
    }

    /**
     * 教师请假
     *
     * @param listener
     * @param map
     */
    @Override
    public void getLeave(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().getLeave(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1224-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("leave", subscription);
    }

    /**
     * 教师添加隐患
     *
     * @param listener
     * @param map
     */
    @Override
    public void getAddHidden(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().getAddHidden(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1352-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("addhidden", subscription);
    }

    /**
     * 隐患管理
     *
     * @param listener
     * @param map
     */
    @Override
    public void getHiddenManager(final OnApiListener listener, Map<String, String> map) {
        Observable<HiddenManagerBean> observable = RetrofitClint.getApi().getHiddenManager(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<HiddenManagerBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1394-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(HiddenManagerBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("hiddenmanager", subscription);
    }

    /**
     * 发布通知
     *
     * @param listener
     * @param map
     */
    @Override
    public void postInfrom(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postInfrom(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1436-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("infrom", subscription);
    }

    /**
     * 获取宝宝家长列表
     *
     * @param listener
     * @param map
     */
    @Override
    public void getBabyParents(final OnApiListener listener, Map<String, String> map) {
        Observable<BabyParentsBean> observable = RetrofitClint.getApi().getBabyParents(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BabyParentsBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1480-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(BabyParentsBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("babyparents", subscription);
    }

    /**
     * 我发布的通知
     *
     * @param listener
     * @param map
     */
    @Override
    public void getReleaseInfrom(final OnApiListener listener, Map<String, String> map) {
        Observable<InfromBean> observable = RetrofitClint.getApi().getReleaseInfrom(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<InfromBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1522-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(InfromBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("infromrelease", subscription);
    }

    /**
     * 上传头像
     *
     * @param listener
     * @param map
     */
    @Override
    public void postHeader(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postHeader(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1522-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("postheader", subscription);
    }

    /**
     * 我收到的通知
     *
     * @param listener
     * @param map
     */
    @Override
    public void getReadInfrom(final OnApiListener listener, Map<String, String> map) {
        Observable<InfromBean> observable = RetrofitClint.getApi().getReadInfrom(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<InfromBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1522-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(InfromBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("infromread", subscription);
    }

    /**
     * 获取关于我们数据
     *
     * @param listener
     * @param map
     */
    @Override
    public void getAbout(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().getAbout(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1648-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("response", subscription);
    }

    /**
     * 反馈信息
     *
     * @param listener
     * @param map
     */
    @Override
    public void postFeedBack(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().postFeedBack(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1690-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("feebback", subscription);
    }

    /**
     * 获取系统公告数据
     *
     * @param listener
     * @param map
     */
    @Override
    public void getSystemNotice(final OnApiListener listener, Map<String, String> map) {
        Observable<ResponseBean> observable = RetrofitClint.getApi().getSystemNotice(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<ResponseBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1648-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(ResponseBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("systemnotice", subscription);
    }

    /**
     * 获取app最新版本
     *
     * @param listener
     * @param map
     */
    @Override
    public void getAppUpdate(final OnApiListener listener, Map<String, String> map) {
        Observable<AppUpdateBean> observable = RetrofitClint.getApi().getAppUpdate(map);
        Subscription subscription = observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<AppUpdateBean>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onStart() {
                        super.onStart();
                    }

                    @Override
                    public void onError(Throwable e) {
                        Log.e(TAG, "1648-e：" + e.toString());
                        if (listener != null) {
                            listener.onError(e.toString());
                        }
                    }

                    @Override
                    public void onNext(AppUpdateBean bean) {
                        if (bean != null) {
                            Log.e(TAG, "bean:" + bean.toString());
                            if (listener != null) {
                                listener.onSuccess(bean);
                            }
                        }
                    }
                });
        RxApiManager.getsInstance().add("updateapp", subscription);
    }
}